#pragma once
#ifndef __G_COORD_FRAME_3_H__
#define __G_COORD_FRAME_3_H__

#include "GVector3.h"
#include "GMatrix4x4.h"
#include "GQuaternion.h"
#include "GUtilities/GTypes.h"
#include "GUtilities/GBitContainer.h"

namespace GMath
{

	typedef GUtil::GFlag				GFrame3DirtyFlags;
	#define G_F3DF_DIRTY_TRANSFORM		0x0001
	#define G_F3DF_DIRTY_RIGHT			0x0002
	#define G_F3DF_DIRTY_UP				0x0004
	#define G_F3DF_DIRTY_FRONT			0x0008
	#define G_F3DF_DIRTY_AXIS			G_F3DF_DIRTY_RIGHT | G_F3DF_DIRTY_UP | G_F3DF_DIRTY_FRONT


	class GCoordFrame3
	{
	public:
		static const GCoordFrame3	Identitiy;

	protected:
		GVector3					Scale;
		GVector3					Position;
		GQuaternion					Rotation;
		
		mutable GMatrix4x4			Transformation;

		mutable GVector3			Right;
		mutable GVector3			Up;
		mutable GVector3			Front;

		mutable GFrame3DirtyFlags	Flags;

		virtual void				OnTransformChange();

	public:
									GCoordFrame3();
									GCoordFrame3(const GCoordFrame3& Frame);
									GCoordFrame3(const GVector3& Scale, const GQuaternion& Rotation, const GVector3& Position);
		virtual						~GCoordFrame3();

		GFrame3DirtyFlags			GetFlags() const;

		void						SetScale(const GVector3& NewScale);
		const GVector3&				GetScale() const;

		void						SetPosition(const GVector3& NewPosition);
		const GVector3&				GetPosition() const;

		void						SetRotation(const GQuaternion& NewRotation);
		const GQuaternion&			GetRotation() const;

		void						SetTransformation(const GMatrix4x4& Matrix);
		const GMatrix4x4&			GetTransformation() const;

		const GVector3&				GetRight() const;
		const GVector3&				GetUp() const;
		const GVector3&				GetFront() const;

		const GCoordFrame3&		operator = (const GCoordFrame3& Frame);

		

	};

}

#endif